<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>News</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link type="text/css" rel="stylesheet" href="css/picnews.css" />
	<link type="text/css" rel="stylesheet" href="../../css/pepper-grinder/jquery-ui-1.8.16.custom.css" />
	<script type="text/javascript" src="../../js/jquery.min.js"></script>
	<script type="text/javascript" src="../../js/jquery-ui-1.8.16.custom.min.js"></script>
	<script type="text/javascript" src="js/jquery.tabswitch.js"></script>
	<script type="text/javascript" src="../../js/jquery.mousewheel.min.js"></script>
	<script type="text/javascript" src="../../js/popeScroll.js"></script>
	<script language="JavaScript" type="text/JavaScript">
		var tabnum = 0;
		var maxtabnum = 2;
		$(document).ready(function() {
			$(window).resize(function() {
				refresh();
			});	
			refresh();
			var parwinwidth = $(window.parent).width();
			var parwinheight = $(window.parent).height();
			$("#leftButton,#rightButton").hover(function(){
				$(this).removeClass("transparent_0");
				$(this).addClass("transparent_class");
			},function(){
				$(this).removeClass("transparent_class");
				$(this).addClass("transparent_0");
			});
			$(".subtab").tabSwitch("create", {type: "slide", height: parwinheight*0.8, width: parwinwidth/2-5},function(){
				
			});
			
			$.getJSON("picnews_getNewsByTypeByTime.do",{length:"30",type:"冷一下"},function(json){
				for(var i=0;i<json.length;i++){
					
					var index = "1";
					var divstr = getDivStr(json[i]);
					addConToHtml(i,index,divstr);
				}
				refresh();
			});
			$.getJSON("picnews_getNewsByTypeByTime.do",{length:"30",type:"囧图"},function(json){
				for(var i=0;i<json.length;i++){
					
					var index = "2";
					var divstr = getDivStr(json[i]);
					addConToHtml(i,index,divstr);
				}
				refresh();
			});
			$.getJSON("picnews_getNewsByTypeByTime.do",{length:"30",type:"妹纸"},function(json){
				for(var i=0;i<json.length;i++){
					
					var index = "3";
					var divstr = getDivStr(json[i]);
					addConToHtml(i,index,divstr);
				}
				refresh();
			});
			
			$("#con_1").popeScroll({
				offset_top:-300,
				top:25,
				mousewheelBox:"tabscontent"
			});
			

		});
		function refresh(){
			var winheight = $(window).height();
			var winwidth = $(window).width();
			
			$("#bodydiv").css("height",winheight);
			$(".subtab").css("height",winheight-5);
			
			
		}
		
		function changeTab(num){
			var tmp = tabnum + num;
			
			if(tmp < 0|| tmp > maxtabnum){
				return;
			}
			tabnum = tmp;
			$(".popeScroll").hide();
			var index = tabnum+1;
			
			var $scroll = $("#scroll_con_"+index);
			if($scroll.length==0){
				
				$("#con_"+index).popeScroll({
					offset_top:-300,
					top:25,
					mousewheelBox:"tabscontent"
				});
			}else{
				$scroll.show();
			}
			$(".subtab").tabSwitch("moveTo",{index: tabnum},function(){
					
			});
		}
		
		function getDivStr(json){
			var divstr = "";
			var type = json.type;
			var id = json.id;
			var title = json.title;
			var time = json.createtime;
			var description = json.description;
			var cover = json.cover;
			
			divstr = divstr + '<div class="newsimg"><img onclick="showNews(\''+id+'\');" title="点击查看" src="'+cover+'" /></div>';
			divstr = divstr + '<div class="newstitle" onclick="showNews(\''+id+'\');" >'+title+'</div>';
			divstr = divstr + '<div class="newstitle2">'+time+'</div>';
			divstr = divstr + '<div class="newsdes"><p/>'+description+'<p/></div>';
			return divstr;
			
		}
		
		function addConToHtml(i,index,divstr){
			if(i%3==0){
				$("#left_"+index).append(divstr);
			}
			if(i%3==1){
				$("#center_"+index).append(divstr);
			}
			if(i%3==2){
				$("#right_"+index).append(divstr);
			}
		}
		
		function showNews(id){
			window.parent.resizeWin("picnews1",0.4,0.9);
			window.location.href = "shownews.html?id="+id;
			
		}
		
	</script>
</head>
<body style="background-color=transparent;width:100%;margin-left:0px;margin-top:0px;">
	<div id="bodydiv" style="background:url(../../image/bg/9.png)">
		
		<div id="tabscontent" >
			<div id="tab-1" class="subtab">
				<div class="tabtitle">冷一下</div>
				<div id="con_1" style="width:80%;padding-left:10%;float:left;" class="newscon">
					<div id="left_1" style="float:left;width:33%;" >
						
							
					</div>
					<div id="center_1" style="float:left;width:33%;" >
					
					</div>
					<div id="right_1" style="float:left;width:33%;" >
					
					</div>
				</div>
			</div>
			<div id="tab-2" class="subtab">
				<div class="tabtitle">囧图</div>
				<div id="con_2" style="width:80%;padding-left:10%;float:left;" class="newscon">
					<div id="left_2" style="float:left;width:33%;" >
						
							
					</div>
					<div id="center_2" style="float:left;width:33%;" >
					
					</div>
					<div id="right_2" style="float:left;width:33%;" >
					
					</div>
				</div>
			</div>
			<div id="tab-3" class="subtab">
				<div class="tabtitle">妹纸</div>
				<div id="con_3" style="width:80%;padding-left:10%;float:left;" class="newscon">
					<div id="left_3" style="float:left;width:33%;" >
						
							
					</div>
					<div id="center_3" style="float:left;width:33%;" >
					
					</div>
					<div id="right_3" style="float:left;width:33%;" >
					
					</div>
				</div>
			</div>
			
		
		</div>
		<div id="leftButton" class="leftButton transparent_0" onclick="changeTab(-1);"><img title="上一个" src="image/left.png" /></div>
		<div id="rightButton" class="rightButton transparent_0" onclick="changeTab(1);"><img title="下一个" src="image/right.png" /></div>
			

		
	</div>
	
	
</body>
</html>